<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="author" content="何毓堂">
    <title></title>
    <link rel="stylesheet" type="" href="">
    <style>
        * {
            box-sizing: border-box;
        }

        ul {
            padding: 0;
            margin: 0;
            list-style: none;
        }

        .box {
            width: 790px;
            height: 280px;
            margin: 100px auto;
            position: relative;
        }

        .img-list li {
            position: absolute;
            top: 0;
            left: 0;
            display: none;
        }

        .img-list li.current {
            display: block;
        }

        .indicator {
            width: 300px;
            position: absolute;
            left: 240px;
            bottom: -20px;
            display: flex;
            justify-content: center;
            color: white;
            /* border: 2px solid violet; */
            background-color: hsla(0, 0%, 100%, .4);
            border-radius: 12px;
        }

        .indicator li {
            width: 20px;
            height: 20px;
            background-color: #fff;
            text-align: center;
            line-height: 20px;
            margin: 0 5px;
            border-radius: 50%;
            cursor: pointer;
        }

        .indicator li.active {
            background-color: red;
        }

        .img-click span {
            width: 30px;
            height: 40px;
            line-height: 40px;
            text-align: center;
            color: white;
            background-color: rgba(0, 0, 0, 0.1);
            position: absolute;
            top: calc(50% - 20px);
            display: none;
        }

        .img-click span:hover {
            background-color: orange;
            cursor: pointer;
        }

        .img-click .prev {
            left: 0;
        }

        .img-click .next {
            right: 0;
        }
    </style>
</head>

<body>
    <div class="box">
        <ul class="img-list">
            <li class="current"><a href="#"><img src="京东图片\01.jpg" alt=""></a></li>
            <li><a href="#"><img src="京东图片\02.jpg" alt=""></a></li>
            <li><a href="#"><img src="京东图片\03.jpg" alt=""></a></li>
            <li><a href="#"><img src="京东图片\04.jpg" alt=""></a></li>
            <li><a href="#"><img src="京东图片\05.jpg" alt=""></a></li>
            <li><a href="#"><img src="京东图片\06.jpg" alt=""></a></li>
            <li><a href="#"><img src="京东图片\07.jpg" alt=""></a></li>
            <li><a href="#"><img src="京东图片\08.jpg" alt=""></a></li>
        </ul>
        <ul class="indicator">
            <li class="active"></li>
            <li>1</li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>
        <div class="img-click">
            <span class="prev">&lt;</span>
            <span class="next">&gt;</span>
        </div>

    </div>
</body>

</html>
<script>
    window.onload = function () {
        var box = document.querySelector('.box');
        var imgLis = document.querySelectorAll('.img-list li');
        var indicatorLis = document.querySelectorAll('.indicator li');
        var prev = document.querySelector('.prev');
        var next = document.querySelector('.next');
        var index = 0;
        function prevImg() {
            index = index == 0 ? index = imgLis.length - 1 : index - 1;
            showImg();
        }
        function nextImg() {
            index = index == imgLis.length - 1 ? 0 : index + 1;
            showImg();
        }
        function showImg() {
            for (var i = 0; i < imgLis.length; i++) {
                imgLis[i].className = '';
                indicatorLis[i].className = '';
            }
            imgLis[index].className = 'current';
            indicatorLis[index].className = 'active';
        }

        var timer = setInterval(nextImg, 1500);
        for (var i = 0; i < indicatorLis.length; i++) {
            indicatorLis[i].index = i;
            indicatorLis[i].onmouseover = function () {
                clearInterval(timer);
                timer = null;
                index = this.index;
                showImg();
            }
            indicatorLis[i].onmouseout = function () {
                if (timer) return;
                timer = setInterval(nextImg, 1000);
            }
        }

        box.onmouseover = function () {
            clearInterval(timer);
            timer = null;
            prev.style.display = 'block';
            next.style.display = 'block';
        }
        box.onmouseout = function () {
            if (timer) return;
            timer = setInterval(nextImg, 1000);
            prev.style.display = 'none';
            next.style.display = 'none';
        }
        prev.onclick = function () {
            prevImg();
        }
        next.onclick = function () {
            nextImg();
        }


        
    }

</script>